//
//  DestnationCountryDiscountRootVC.m
//  AroundTheWorld
//
//  Created by dllo on 16/5/19.
//  Copyright © 2016年 IfelseGo an. All rights reserved.
//

#import "DestnationCountryDiscountRootVC.h"
#import "DestnationCountryDiscountSuperVC.h"
#import "DestnationCountryDiscountWonderfulVC.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface DestnationCountryDiscountRootVC ()

@property (nonatomic, strong) DestnationCountryDiscountSuperVC *superVC;
@property (nonatomic, strong) DestnationCountryDiscountWonderfulVC *wonderfulVC;

@end

@implementation DestnationCountryDiscountRootVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title  =  @"特价折扣";
    
    
    UIImage *image = [[UIImage imageNamed:@"btn_mine_fanhui"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemAction)];
    
    
    self.superVC = [[DestnationCountryDiscountSuperVC alloc] init];
    self.wonderfulVC = [[DestnationCountryDiscountWonderfulVC alloc] init];
    
    //将firstVC设置为rootVC的子视图控制器
    [self addChildViewController:self.superVC];
    [self.view addSubview:self.superVC.view];
    
    [self addChildViewController:self.wonderfulVC];
    [self.view addSubview:self.wonderfulVC.view];

    UIButton *superButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [superButton setTitle:@"超级自由行" forState:UIControlStateNormal];
    superButton.frame = CGRectMake(0, 0, WIDTH / 2, 50);
    [superButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.view addSubview:superButton];
    [superButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *wonderfulButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [wonderfulButton setTitle:@"精彩当地游" forState:UIControlStateNormal];
    [wonderfulButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    wonderfulButton.frame = CGRectMake(WIDTH / 2, 0, WIDTH / 2, 50);
    [self.view addSubview:wonderfulButton];
    [wonderfulButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    // Do any additional setup after loading the view.
}

//导航栏返回按钮

- (void)leftBarButtonItemAction
{
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}

- (void) buttonAction:(UIButton *)button
{
    if (button.selected == YES) {
        [self.view bringSubviewToFront:self.superVC.view];
    }else{
        [self.view bringSubviewToFront:self.wonderfulVC.view];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
